import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { v4 as uuidv4 } from 'uuid';
import { User } from '../../user/entities/user.entity';

@Entity('user_shopId')
export class UserShopId {
  @PrimaryGeneratedColumn({ type: 'int' })
  id: number;

  @Column({
    type: 'varchar',
    length: 36, // 使用长度为36的字符串，因为 UUID 是36个字符
    comment: '店铺ID',
    nullable: false,
    default: () => `'${uuidv4().replace(/-/g, '')}'`, // 去掉连字符 "-"
  })
  shopId: string;

  @Column({
    type: 'varchar',
    comment: '店铺名',
    nullable: false,
  })
  shopName: string;

  // 拥有这个店铺的商家
  @ManyToOne(() => User, (user) => user.shopId)
  user: User;
}
